package Protocoltcp;/*

 */

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @ClassName MyMessageEncoder
 * @Author Final
 * @Project DataStructures
 */
public class MyMessageEncoder extends MessageToByteEncoder<MessageProtocol> {
    @Override
    protected void encode(ChannelHandlerContext ctx, MessageProtocol msg, ByteBuf out) throws Exception {

        System.out.println("encoder方法被调用");

        out.writeInt(msg.getLen());
        out.writeBytes(msg.getContent());
    }
}
